package com.atguigu.spzx.manner.controller;

import com.atguigu.spzx.manner.service.SystemUserService;
import com.atguigu.spzx.model.dto.SysUserDto;
import com.atguigu.spzx.model.entity.SysRole;
import com.atguigu.spzx.model.entity.SysUser;
import com.atguigu.spzx.model.myemun.ResultCodeEnum;
import com.atguigu.spzx.model.vo.common.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/system/sysUser")
@CrossOrigin(allowCredentials = "true", originPatterns = "*", allowedHeaders = "*")
public class SysUserController {
    @Autowired
    SystemUserService systemUserService;
    @GetMapping("/findByPage/{pageNum}/{pageSize}")
    public Result<PageInfo<SysUser>> findByPage(@PathVariable("pageNum") Integer pageNum,
                                                @PathVariable("pageSize") Integer pageSize,
                                                SysUserDto sysUserDto) {
        PageInfo<SysUser>result= systemUserService.findByPage(pageNum, pageSize, sysUserDto);
        return Result.build(result, ResultCodeEnum.SUCCESS);
    }
    @PutMapping("/updateSysUser")
    public Result updateSysRole(@RequestBody SysUser sysUser) {
        systemUserService.updateSysRole(sysUser);
        return Result.build(ResultCodeEnum.SUCCESS);
    }
    @PostMapping("/saveSysUser")
    public Result saveSysRole(@RequestBody SysUser sysUser) {
        systemUserService.saveSysRole(sysUser);
        return Result.build(ResultCodeEnum.SUCCESS);
    }
    @DeleteMapping("/deleteSysUserById/{id}")
    public Result deleteSysUserById(@PathVariable("id") Long id) {
        systemUserService.deleteSysUserById(id);
        return Result.build(ResultCodeEnum.SUCCESS);
    }

}
